﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TravellerLib {
  /// <summary>
  /// The Travellers' Aid Society travel zone for a system.
  /// </summary>
  public enum Zone {
    /// <summary>
    /// Normal: no travel warnings.
    /// </summary>
    Normal = 0,
    /// <summary>
    /// Amber travel zones indicate that travellers should exercise caution when visiting such worlds.
    /// </summary>
    Amber = 1,
    /// <summary>
    /// Red travel zone usually indicates that a major danger exists within the system.
    /// </summary>
    Red = 2
  }
  /// <summary>
  /// An individual star system.  Data stored is mostly about the system's primary world.
  /// </summary>
  public class StarSystem {
    /// <summary>
    /// Gets or sets the name.
    /// </summary>
    /// <value>
    /// The name.
    /// </value>
    public string Name { get; set; }
    /// <summary>
    /// Gets or sets the number of planets.
    /// </summary>
    /// <value>
    /// The planets.
    /// </value>
    public int Planets { get; set; }
    /// <summary>
    /// Gets or sets the number of gas giants.
    /// </summary>
    /// <value>
    /// The gas giants.
    /// </value>
    public int GasGiants { get; set; }
    /// <summary>
    /// Gets or sets the number of belts.
    /// </summary>
    /// <value>
    /// The belts.
    /// </value>
    public int Belts { get; set; }
    /// <summary>
    /// Gets or sets the UWP of the primary world.
    /// </summary>
    /// <value>
    /// The UWP.
    /// </value>
    public string UWP { get; set; }
    /// <summary>
    /// Gets or sets the code for bases in the system.
    /// </summary>
    /// <value>
    /// The bases.
    /// </value>
    public string Bases { get; set; }
    /// <summary>
    /// Gets or sets the remarks, such as trade classifications.
    /// </summary>
    /// <value>
    /// The remarks.
    /// </value>
    public string Remarks { get; set; }
    /// <summary>
    /// Gets or sets the TAS zone.
    /// </summary>
    /// <value>
    /// The zone.
    /// </value>
    public Zone Zone { get; set; }
    /// <summary>
    /// Gets or sets the allegiance of the system.
    /// </summary>
    /// <value>
    /// The allegiance.
    /// </value>
    public string Allegiance { get; set; }
    /// <summary>
    /// Gets the parent <see cref="SubSector"/> of this system.
    /// </summary>
    /// <value>
    /// The parent.
    /// </value>
    public SubSector Parent { get; private set; }
    /// <summary>
    /// Gets the hex coordinate of this system.
    /// </summary>
    /// <value>
    /// The hex.
    /// </value>
    public string Hex { get; private set; }
    /// <summary>
    /// Initializes a new instance of the <see cref="StarSystem" /> class.
    /// </summary>
    /// <param name="name">The name.</param>
    /// <param name="hex">The hex.</param>
    /// <param name="uwp">The uwp.</param>
    /// <param name="bases">The bases.</param>
    /// <param name="remarks">The remarks.</param>
    /// <param name="zone">The zone.</param>
    /// <param name="pbg">The counts of planets, belts, and gas giants.</param>
    /// <param name="alleg">The allegiance.</param>
    public StarSystem(string name = "", string hex = "0000", string uwp = "0000000-0", string bases = "", string remarks = "", Zone zone = Zone.Normal, string pbg = "000", string alleg = "") :
      this(name, hex, uwp, bases, remarks, zone, Convert.ToInt32(pbg.Substring(0, 1)), Convert.ToInt32(pbg.Substring(2, 1)), Convert.ToInt32(pbg.Substring(1, 1)), alleg) { }
    /// <summary>
    /// Initializes a new instance of the <see cref="StarSystem" /> class.
    /// </summary>
    /// <param name="name">The name.</param>
    /// <param name="hex">The hex.</param>
    /// <param name="uwp">The uwp.</param>
    /// <param name="bases">The bases.</param>
    /// <param name="remarks">The remarks.</param>
    /// <param name="zone">The zone.</param>
    /// <param name="planets">The planets.</param>
    /// <param name="giants">The giants.</param>
    /// <param name="belts">The belts.</param>
    /// <param name="allegiance">The allegiance.</param>
    public StarSystem(string name = "", string hex = "0000", string uwp = "0000000-0", string bases = "", string remarks = "", Zone zone = Zone.Normal, int planets = 0, int giants = 0, int belts = 0, string allegiance = "") {
      Name = name;
      Hex = hex;
      UWP = uwp;
      Bases = bases.TrimEnd();
      Remarks = remarks.TrimEnd();
      Zone = zone;
      Planets = planets;
      GasGiants = giants;
      Belts = belts;
      Allegiance = allegiance;
    }
    /// <summary>
    /// Returns a <see cref="System.String" /> that represents this instance.
    /// </summary>
    /// <returns>
    /// A <see cref="System.String" /> that represents this instance.
    /// </returns>
    public override string ToString() {
      return "System: " + Name + " (" + Hex + ")";
    }
  }
}
